import { ExtensionContext, workspace, window } from 'vscode';

export class ConfigUtil {
    public static getCurPageNumber(): number {
        let val = workspace.getConfiguration().get(EConfig.currPageNumber) as number;
        return val;
    }

    public static setCurPageNumber(val: number) {
        workspace.getConfiguration().update(EConfig.currPageNumber, val, true);
    }

    public static getPageSize(): number {
        let val = 0;
        val = workspace.getConfiguration().get(EConfig.pageSize) || 50;
        return val;
    }

    public static setPageSize(val: number) {
        workspace.getConfiguration().update(EConfig.pageSize, val, true);
    }

    public static getFilePath(): string {
        let val = workspace.getConfiguration().get(EConfig.filePath) as string;
        return val;
    }

    public static setFilePath(bookPath: string) {
        workspace.getConfiguration().update(EConfig.filePath, bookPath, true);
    }
}

export enum EConfig {
    currPageNumber = 'thiefBook.currPageNumber',
    pageSize = 'thiefBook.pageSize',
    filePath = 'thiefBook.filePath'
}

export interface ICatchConfig {
    name: string;
    url: string;
    start: string;
    end: string;
    regex: string;
    detailRegex?: string;
}

export interface ICatchDetailConfig {
    name: string;
    urls: string;
    requestGroupName: string;
}